package gold.digger;

import gold.utils.InputUtil;

import java.util.*;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC1200 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public List<List<Integer>> minimumAbsDifference(int[] arr) {
            Arrays.sort(arr);
            TreeMap<Integer, List<List<Integer>>> ansMap = new TreeMap<>();
            for (int i = 0; i < arr.length - 1; i++) {
                int interval = arr[i + 1] - arr[i];
                if (!ansMap.containsKey(interval)) ansMap.put(interval, new ArrayList<>());
                ansMap.get(interval).add(new ArrayList<>(Arrays.asList(arr[i], arr[i + 1])));
            }

            return ansMap.get(ansMap.keySet().stream().iterator().next());
        }
    }

    public void run() {
        System.out.println(new Solution().minimumAbsDifference(InputUtil.toIntegerArray("[1,2,3]")));
    }

    public static void main(String[] args) throws Exception {
        LC1200 an = new LC1200();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
